<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
    <script src="https://unpkg.com/vue"></script>
  </head>
  <body>
    <div id="app"><!-- render函数的作用和template一样 优先级更高 -->
        <anchored-heading :level="2">Hello world!</anchored-heading>
    </div>
    <script type="text/x-template" id="anchored-heading-template">
      <h1 v-if="level === 1">
        <slot></slot>
      </h1>
      <h2 v-else-if="level === 2">
        <slot></slot>
      </h2>
      <h3 v-else-if="level === 3">
        <slot></slot>
      </h3>
      <h4 v-else-if="level === 4">
        <slot></slot>
      </h4>
      <h5 v-else-if="level === 5">
        <slot></slot>
      </h5>
      <h6 v-else-if="level === 6">
        <slot></slot>
      </h6>
    </script>
    <script>
      Vue.component("anchored-heading", {
        template: "#anchored-heading-template",   //要么写成template: `<div>111</div>`
        props: {
          level: {
            type: Number,
            required: true
          }
        }
      });
      new Vue({
          el: '#app'
      })
    </script>
  </body>
</html>
